package com.house.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.house.common.pojo.EUDataGridResult;
import com.house.mapper.HousefloorMapper;
import com.house.pojo.Housefloor;
import com.house.pojo.HousefloorExample;

import com.house.pojo.HousefloorExample.Criteria;
import com.house.service.HousefloorService;

@Service
public class HousefloorServiceImpl implements HousefloorService {

	@Autowired
	private HousefloorMapper housefloorMapper;
	@Override
	public EUDataGridResult getFloorList(int page, int rows) {
		HousefloorExample example = new HousefloorExample();
		//设置分页
		PageHelper.startPage(page, rows);
		
		List<Housefloor> list = housefloorMapper.selectByExample(example);
		//取分页信息
		PageInfo<Housefloor> pageInfo = new PageInfo<>(list);

		EUDataGridResult result = new EUDataGridResult();
		result.setRows(list);
		result.setTotal(pageInfo.getTotal());
		return result;
	}
	
	@Override
	public int delete(List<Integer> id) {
		// TODO Auto-generated method stub
		HousefloorExample example = new HousefloorExample();
		Criteria criteria = example.createCriteria();
		criteria.andIdIn(id);		
		return housefloorMapper.deleteByExample(example);
	}

	@Override
	public int add(Housefloor floor) {
		// TODO Auto-generated method stub
		return housefloorMapper.insert(floor);
	}

}
